home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / OpenBSD / comp21.tar.gz / comp21.tar / usr / include / scsi / scsi_all.h next >
C/C++ Source or Header  |  1997-04-14  |  6KB  |  303 lines

  1. /*    $OpenBSD: scsi_all.h,v 1.5 1997/04/14 04:09:06 downsj Exp $    */
  2. /*    $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $    */
  3.  
  4. /*
  5.  * SCSI general  interface description
  6.  */
  7.  
  8. /*
  9.  * Largely written by Julian Elischer (julian@tfs.com)
  10.  * for TRW Financial Systems.
  11.  *
  12.  * TRW Financial Systems, in accordance with their agreement with Carnegie
  13.  * Mellon University, makes this software available to CMU to distribute
  14.  * or use in any manner that they see fit as long as this message is kept with 
  15.  * the software. For this reason TFS also grants any other persons or
  16.  * organisations permission to use or modify this software.
  17.  *
  18.  * TFS supplies this software to be publicly redistributed
  19.  * on the understanding that TFS is not responsible for the correct
  20.  * functioning of this software in any circumstances.
  21.  *
  22.  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
  23.  */
  24.  
  25. #ifndef    _SCSI_SCSI_ALL_H
  26. #define _SCSI_SCSI_ALL_H 1
  27.  
  28. /*
  29.  * SCSI command format
  30.  */
  31.  
  32. /*
  33.  * Define dome bits that are in ALL (or a lot of) scsi commands
  34.  */
  35. #define SCSI_CTL_LINK        0x01
  36. #define SCSI_CTL_FLAG        0x02
  37. #define SCSI_CTL_VENDOR        0xC0
  38.  
  39.  
  40. /*
  41.  * Some old SCSI devices need the LUN to be set in the top 3 bits of the
  42.  * second byte of the CDB.
  43.  */
  44. #define    SCSI_CMD_LUN_MASK    0xe0
  45. #define    SCSI_CMD_LUN_SHIFT    5
  46.  
  47.  
  48. struct scsi_generic {
  49.     u_int8_t opcode;
  50.     u_int8_t bytes[11];
  51. };
  52.  
  53. struct scsi_test_unit_ready {
  54.     u_int8_t opcode;
  55.     u_int8_t byte2;
  56.     u_int8_t unused[3];
  57.     u_int8_t control;
  58. };
  59.  
  60. struct scsi_send_diag {
  61.     u_int8_t opcode;
  62.     u_int8_t byte2;
  63. #define    SSD_UOL        0x01
  64. #define    SSD_DOL        0x02
  65. #define    SSD_SELFTEST    0x04
  66. #define    SSD_PF        0x10
  67.     u_int8_t unused[1];
  68.     u_int8_t paramlen[2];
  69.     u_int8_t control;
  70. };
  71.  
  72. struct scsi_sense {
  73.     u_int8_t opcode;
  74.     u_int8_t byte2;
  75.     u_int8_t unused[2];
  76.     u_int8_t length;
  77.     u_int8_t control;
  78. };
  79.  
  80. struct scsi_inquiry {
  81.     u_int8_t opcode;
  82.     u_int8_t byte2;
  83.     u_int8_t unused[2];
  84.     u_int8_t length;
  85.     u_int8_t control;
  86. };
  87.  
  88. struct scsi_mode_sense {
  89.     u_int8_t opcode;
  90.     u_int8_t byte2;
  91. #define    SMS_DBD                0x08
  92.     u_int8_t page;
  93. #define    SMS_PAGE_CODE             0x3F
  94. #define    SMS_PAGE_CTRL             0xC0
  95. #define    SMS_PAGE_CTRL_CURRENT         0x00
  96. #define    SMS_PAGE_CTRL_CHANGEABLE     0x40
  97. #define    SMS_PAGE_CTRL_DEFAULT         0x80
  98. #define    SMS_PAGE_CTRL_SAVED         0xC0
  99.     u_int8_t unused;
  100.     u_int8_t length;
  101.     u_int8_t control;
  102. };
  103.  
  104. struct scsi_mode_sense_big {
  105.     u_int8_t opcode;
  106.     u_int8_t byte2;        /* same bits as small version */
  107.     u_int8_t page;         /* same bits as small version */
  108.     u_int8_t unused[4];
  109.     u_int8_t length[2];
  110.     u_int8_t control;
  111. };
  112.  
  113. struct scsi_mode_select {
  114.     u_int8_t opcode;
  115.     u_int8_t byte2;
  116. #define    SMS_SP    0x01
  117. #define    SMS_PF    0x10
  118.     u_int8_t unused[2];
  119.     u_int8_t length;
  120.     u_int8_t control;
  121. };
  122.  
  123. struct scsi_mode_select_big {
  124.     u_int8_t opcode;
  125.     u_int8_t byte2;        /* same bits as small version */
  126.     u_int8_t unused[5];
  127.     u_int8_t length[2];
  128.     u_int8_t control;
  129. };
  130.  
  131. struct scsi_reserve {
  132.     u_int8_t opcode;
  133.     u_int8_t byte2;
  134.     u_int8_t unused[2];
  135.     u_int8_t length;
  136.     u_int8_t control;
  137. };
  138.  
  139. struct scsi_release {
  140.     u_int8_t opcode;
  141.     u_int8_t byte2;
  142.     u_int8_t unused[2];
  143.     u_int8_t length;
  144.     u_int8_t control;
  145. };
  146.  
  147. struct scsi_prevent {
  148.     u_int8_t opcode;
  149.     u_int8_t byte2;
  150.     u_int8_t unused[2];
  151.     u_int8_t how;
  152.     u_int8_t control;
  153. };
  154. #define    PR_PREVENT 0x01
  155. #define PR_ALLOW   0x00
  156.  
  157. struct scsi_changedef {
  158.     u_int8_t opcode;
  159.     u_int8_t byte2;
  160.     u_int8_t unused1;
  161.     u_int8_t how;
  162.     u_int8_t unused[4];
  163.     u_int8_t datalen;
  164.     u_int8_t control;
  165. };
  166. #define SC_SCSI_1 0x01
  167. #define SC_SCSI_2 0x03
  168.  
  169. /*
  170.  * Opcodes
  171.  */
  172. #define    TEST_UNIT_READY        0x00
  173. #define REQUEST_SENSE        0x03
  174. #define INQUIRY            0x12
  175. #define MODE_SELECT        0x15
  176. #define MODE_SENSE        0x1a
  177. #define START_STOP        0x1b
  178. #define RESERVE              0x16
  179. #define RELEASE              0x17
  180. #define PREVENT_ALLOW        0x1e
  181. #define POSITION_TO_ELEMENT    0x2b
  182. #define    CHANGE_DEFINITION    0x40
  183. #define    MODE_SENSE_BIG        0x54
  184. #define    MODE_SELECT_BIG        0x55
  185.  
  186. /*
  187.  * Sort of an extra one, for SCSI_RESET.
  188.  */
  189. #define GENRETRY        1
  190.  
  191. /*
  192.  * sense data format
  193.  */
  194. #define T_DIRECT    0
  195. #define T_SEQUENTIAL    1
  196. #define T_PRINTER    2
  197. #define T_PROCESSOR    3
  198. #define T_WORM        4
  199. #define T_CDROM        5
  200. #define T_SCANNER     6
  201. #define T_OPTICAL     7
  202. #define T_NODEVICE    0x1F
  203.  
  204. #define T_CHANGER    8
  205. #define T_COMM        9
  206.  
  207. #define T_REMOV        1
  208. #define    T_FIXED        0
  209.  
  210. struct scsi_inquiry_data {
  211.     u_int8_t device;
  212. #define    SID_TYPE    0x1F
  213. #define    SID_QUAL    0xE0
  214. #define    SID_QUAL_LU_OK    0x00
  215. #define    SID_QUAL_LU_OFFLINE    0x20
  216. #define    SID_QUAL_RSVD    0x40
  217. #define    SID_QUAL_BAD_LU    0x60
  218.     u_int8_t dev_qual2;
  219. #define    SID_QUAL2    0x7F
  220. #define    SID_REMOVABLE    0x80
  221.     u_int8_t version;
  222. #define SID_ANSII    0x07
  223. #define SID_ECMA    0x38
  224. #define SID_ISO        0xC0
  225.     u_int8_t response_format;
  226.     u_int8_t additional_length;
  227.     u_int8_t unused[2];
  228.     u_int8_t flags;
  229. #define    SID_SftRe    0x01
  230. #define    SID_CmdQue    0x02
  231. #define    SID_Linked    0x08
  232. #define    SID_Sync    0x10
  233. #define    SID_WBus16    0x20
  234. #define    SID_WBus32    0x40
  235. #define    SID_RelAdr    0x80
  236.     char    vendor[8];
  237.     char    product[16];
  238.     char    revision[4];
  239.     u_int8_t extra[8];
  240. };
  241.  
  242. struct scsi_sense_data_unextended {
  243. /* 1*/    u_int8_t error_code;
  244. /* 4*/    u_int8_t block[3];
  245. };
  246.  
  247. struct scsi_sense_data {
  248. /* 1*/    u_int8_t error_code;
  249. #define    SSD_ERRCODE        0x7F
  250. #define    SSD_ERRCODE_VALID    0x80
  251. /* 2*/    u_int8_t segment;
  252. /* 3*/    u_int8_t flags;
  253. #define    SSD_KEY        0x0F
  254. #define    SSD_ILI        0x20
  255. #define    SSD_EOM        0x40
  256. #define    SSD_FILEMARK    0x80
  257. /* 7*/    u_int8_t info[4];
  258. /* 8*/    u_int8_t extra_len;
  259. /*12*/    u_int8_t cmd_spec_info[4];
  260. /*13*/    u_int8_t add_sense_code;
  261. /*14*/    u_int8_t add_sense_code_qual;
  262. /*15*/    u_int8_t fru;
  263. /*16*/    u_int8_t sense_key_spec_1;
  264. #define    SSD_SCS_VALID    0x80
  265. /*17*/    u_int8_t sense_key_spec_2;
  266. /*18*/    u_int8_t sense_key_spec_3;
  267. /*32*/    u_int8_t extra_bytes[14];
  268. };
  269.  
  270. struct scsi_blk_desc {
  271.     u_int8_t density;
  272.     u_int8_t nblocks[3];
  273.     u_int8_t reserved;
  274.     u_int8_t blklen[3];
  275. };
  276.  
  277. struct scsi_mode_header {
  278.     u_int8_t data_length;    /* Sense data length */
  279.     u_int8_t medium_type;
  280.     u_int8_t dev_spec;
  281.     u_int8_t blk_desc_len;
  282. };
  283.  
  284. struct scsi_mode_header_big {
  285.     u_int8_t data_length[2];    /* Sense data length */
  286.     u_int8_t medium_type;
  287.     u_int8_t dev_spec;
  288.     u_int8_t unused[2];
  289.     u_int8_t blk_desc_len[2];
  290. };
  291.  
  292.  
  293. /*
  294.  * Status Byte
  295.  */
  296. #define    SCSI_OK        0x00
  297. #define    SCSI_CHECK    0x02
  298. #define    SCSI_BUSY    0x08    
  299. #define SCSI_INTERM    0x10
  300. #define SCSI_QUEUE_FULL    0x28
  301.  
  302. #endif /* _SCSI_SCSI_ALL_H */
  303.